package org.iteam.mina.codec;

import java.nio.charset.Charset;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;

/**
 * JMessageProtocal解码编码工厂
 * 
 * @author ke.wen
 * 
 */
public class MessageCodecFactory implements ProtocolCodecFactory {

	private final MessageDecoder decoder;

	private final MessageEncoder encoder;

	public MessageCodecFactory(Charset charset) {
		this.decoder = new MessageDecoder(charset);
		this.encoder = new MessageEncoder(charset);
	}

	public ProtocolDecoder getDecoder(IoSession paramIoSession) throws Exception {
		return decoder;
	}

	public ProtocolEncoder getEncoder(IoSession paramIoSession) throws Exception {
		return encoder;
	}
}